﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using tf2hudmaker.Forms;
using tf2hudmaker.Forms.Editors;

namespace tf2hudmaker
{
    public partial class form_Main : Form
    {
        public form_Main()
        {
            InitializeComponent();

            preview = new form_preview();
            preview.MdiParent = this;
            preview.Show();

            editor_huddamageaccount = new form_huddamageaccount();
            editor_huddamageaccount.MdiParent = this;

            toolbar_preview.ImageScalingSize = new Size(40, 40);
        }

        // Form list
        private form_preview preview;
        public Form currenteditor;
        private Form editor_huddamageaccount;


        private void treeview_AfterSelect(object sender, TreeViewEventArgs e)
        {
            foreach (Form f in this.MdiChildren)
            {
                if (f != preview)
                    f.Hide();
            }

            switch (e.Node.Name)
            {
                case "node_damageheal":
                    {
                        editor_huddamageaccount.Show();
                        this.currenteditor = this.editor_huddamageaccount;

                        form_preview.ChangePreviewList(form_preview.previewlist01);
                        break;
                    }
            }
        }

        private void form_Main_ResizeEnd(object sender, EventArgs e)
        {
            preview.SetSize();
        }

        #region MENUBAR
        #region FILE
        private void menubar_file_exit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
        #endregion

        #region WINDOW
        private void menubar_window_showeditor_Click(object sender, EventArgs e)
        {
            this.currenteditor.Activate();
        }

        private void menubar_window_preview_show_Click(object sender, EventArgs e)
        {
            this.preview.Close();
            this.preview = new form_preview();
            preview.MdiParent = this;
            this.preview.Show();
        }

        private void menubar_window_preview_center_Click(object sender, EventArgs e)
        {
            this.preview.CenterWindow();
        }

        private void menubar_window_preview_close_Click(object sender, EventArgs e)
        {
            this.preview.Close();
        }

        private void menubar_window_preview_restore_Click(object sender, EventArgs e)
        {
            this.preview.SetSize();
        }

        private void menubar_window_preview_maximize_Click(object sender, EventArgs e)
        {
            preview.SetPosition(true);
        }

        private void menubar_window_preview_minimize_Click(object sender, EventArgs e)
        {
            preview.SetPosition(false);
            preview.Size = preview.startingsize;
        }
#endregion

        #region OPTIONS
        private void menubar_option_setdirectory_Click(object sender, EventArgs e)
        {
            new form_setdirectory().ShowDialog();
        }
        #endregion

        #region HELP
        private void menubar_help_about_Click(object sender, EventArgs e)
        {
            form_aboutbox box = new form_aboutbox(this.Location.X + (this.Size.Width / 2), this.Location.Y + (this.Size.Height / 2));
            box.ShowDialog();
        }
        #endregion
        #endregion

        #region TOOLBAR PREVIEW
        private void toolbar_preview_show_Click(object sender, EventArgs e)
        {
            this.preview.Close();
            this.preview = new form_preview();
            preview.MdiParent = this;
            this.preview.Show();
        }

        private void toolbar_preview_close_Click(object sender, EventArgs e)
        {
            this.preview.Close();
        }

        private void toolbar_preview_maximize_Click(object sender, EventArgs e)
        {
            preview.SetPosition(true);
        }

        private void toolbar_preview_minimize_Click(object sender, EventArgs e)
        {
            preview.SetPosition(false);
            preview.Size = preview.startingsize;
        }

        private void toolbar_preview_restore_Click(object sender, EventArgs e)
        {
            this.preview.SetSize();
        }
        #endregion
    }
}
